#! /usr/bin/env python
import rospy

# import srv
from helloworld.srv import *
# return reponse
def callback(req):   
    '''
    req structure:
        num1
        num2
        ---
        sum

    '''
    sum = req.num1 + req.num2
    rospy.loginfo("Server received :num1 = %d, num2 = %d, and sum = %d",req.num1, req.num2, sum)

    # Create Response entity, and send back response
    resp = add_numbersResponse(sum)
    return resp


if __name__ == "__main__":
    #initialize ROS node
    rospy.init_node("Server1")

    # Create server
    server = rospy.Service("add_numbers",add_numbers,callback)
    rospy.loginfo("Server Initialized ")

    # Cycle and Wait
    rospy.spin()